package com.realife.ysuper.controller;

import com.realife.common.utils.R;
import com.realife.ysuper.entity.SpuDetailEntity;
import com.realife.ysuper.service.SpuDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;



/**
 * 
 *
 * @author Albert
 * @email 15962463559@163.com
 * @date 2020-06-05 10:04:15
 */
@Slf4j
@RestController
@RequestMapping("/ysuper/spudetail")
public class SpuDetailController {

    @Autowired
    private SpuDetailService spuDetailService;



    /**
     * 信息
     */
    @RequestMapping("/info/{spuId}")
    //@RequiresPermissions("ysuper:spudetail:info")
    public R info(@PathVariable("spuId") Long spuId){
		SpuDetailEntity spuDetail = spuDetailService.getById(spuId);

        return R.ok().put("spuDetail", spuDetail);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("ysuper:spudetail:save")
    public R save(@RequestBody SpuDetailEntity spuDetail){
		spuDetailService.save(spuDetail);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("ysuper:spudetail:update")
    public R update(@RequestBody SpuDetailEntity spuDetail){
		spuDetailService.updateById(spuDetail);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("ysuper:spudetail:delete")
    public R delete(@RequestBody Long[] spuIds){
		spuDetailService.removeByIds(Arrays.asList(spuIds));

        return R.ok();
    }

}
